#include "Blocks/FluidBlock.h"

namespace PocketSurvival
{
    FluidBlock::FluidBlock(int32_t maxLevel) : m_maxLevel(maxLevel)
    {
        addInheritance(this);
        for(int32_t index = 0; index < 16; ++index)
        {
            float num =  0.875f * MathUtils::Saturate(1.0f - (index / (float)m_maxLevel));
            m_heightByLevel[index] = num;
            m_boundingBoxesByLevel[index].push_back(BoundingBox { Vector3(0.0f), Vector3(1.0f, num, 1.0f) });
        }
    }
    
    const std::vector<BoundingBox> &FluidBlock::getCustomCollisionBoxes(int32_t value)
    {
        return m_boundingBoxesByLevel[GetLevel(Terrain::ExtractData(value))];
    }
    
    BlockPlacementData FluidBlock::getPlacementValue(ComponentMiner *componentMiner, int32_t value, const TerrainRaycastResult &raycastResult)
    {
        BlockPlacementData result;
        result.value = Terrain::ReplaceData(Terrain::ReplaceContents(0, getIndex()), 0);
        result.cellFace = raycastResult.cellFace;
        return result;
    }

    bool FluidBlock::isHeatBlocker(int32_t value)
    {
        return true;
    }

} // namespace PocketSurvival
